package com.martin.lib_base.net

import com.martin.lib_base.BuildConfig
import com.martin.lib_base.base.BaseResponse
import com.martin.lib_base.bean.BaseBean
import com.martin.lib_base.bean.UploadBean
import com.martin.lib_base.bean.UserBean
import com.martin.lib_base.bean.app.ArticleBean
import com.martin.lib_base.bean.app.exchange.GoodsCategoryBean
import com.martin.lib_base.bean.app.goods.GoodsDetailBean
import com.martin.lib_base.bean.app.mall.HomeMallBean
import com.martin.lib_base.bean.app.splash.GuideBean
import okhttp3.MultipartBody
import okhttp3.RequestBody
import okhttp3.ResponseBody
import retrofit2.http.*

/**
 * @author：Houge
 * @date：2022/11/21
 * @desc：
 */
interface Api {

    companion object {
        // 接口地址
        val BASE_URL = if (BuildConfig.env == "release") BuildConfig.baseUrl else BuildConfig.baseUrlTest
    }

    //================================= 功能接口 ==============================================

    @POST("upload/")
    @Multipart
    suspend fun uploadFile(
        @Part file: MultipartBody.Part,
        @PartMap map: MutableMap<String, RequestBody>? = null
    ): BaseResponse<UploadBean>

    @GET
    @Streaming
    @Headers("Calldown: download")
    suspend fun download(@Url url: String): ResponseBody


    //================================= 业务接口 ==============================================

    /**
     * 通用请求
     */
    @POST("appapi/")
    suspend fun <T> commonRequestData(@Body body: RequestBody): BaseResponse<T>

    /**
     * 引导页数据
     */
    @POST("appapi/")
    suspend fun getGuideData(@Body body: RequestBody): BaseResponse<GuideBean>

    /**
     * 系统文章
     */
    @POST("appapi/")
    suspend fun configArticleDetails(@Body body: RequestBody): BaseResponse<ArticleBean>

    /**
     * 退出登录
     */
    @POST("appapi/")
    suspend fun login(@Body body: RequestBody) : BaseResponse<UserBean>

    /**
     * 退出登录
     */
    @POST("appapi/")
    suspend fun logout(@Body body: RequestBody) : BaseResponse<Any>

    /**
     * 用户信息
     */
    @POST("appapi/")
    suspend fun getUserInfo(@Body body: RequestBody) : BaseResponse<UserBean>

    /**
     * 商城首页数据
     */
    @POST("appapi/")
    suspend fun getShopList(@Body body: RequestBody) : BaseResponse<HomeMallBean>

    /**
     * 商品分类数据
     */
    @POST("appapi/")
    suspend fun getCategoryList(@Body body: RequestBody) : BaseResponse<ArrayList<GoodsCategoryBean>>

    /**
     * 商品列表数据
     */
    @POST("appapi/")
    suspend fun getCategoryGoodsList(@Body body: RequestBody) : BaseResponse<HomeMallBean>

    /**
     * 商品详情
     */
    @POST("appapi/")
    suspend fun getGoodsDetailData(@Body body: RequestBody) : BaseResponse<GoodsDetailBean>
}